home *** CD-ROM | disk | FTP | other *** search
- /*
- File: FrameList.cpp
- Contains: Linked list of frames, for use by parts
- Written by: PartMaker
-
- Change History (most recent first):
-
- <3> 4/6/95 TÇ Changed from FacetList to FrameList
- <2> 3/8/95 JS Updated to b1c13/c14
- <1> 2/2/95 RA first checked in
- <0> PartMaker source by Eric Soldan, Tantek Çelik, Jens Alfke, Reggie Adkins
- */
-
- #ifndef _FRAMELIST_
- #include "FrameList.h"
- #endif
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifdef applec
- #pragma segment ProcessMap
- #endif
-
-
- //========================================================================================
- // FrameLink
- //========================================================================================
-
- FrameLink::FrameLink( )
- {
- fFrame = kODNULL;
- fPrev = this;
- fNext = this;
- }
-
- //----------------------------------------------------------------------------------------
-
- FrameLink::FrameLink( ODFrame *frame, FrameLink *list )
- {
- fFrame = frame;
- fPrev = list;
- fNext = list->fNext;
- list->fNext = this;
- fNext->fPrev = this;
- }
-
- //----------------------------------------------------------------------------------------
-
- FrameLink::~FrameLink( )
- {
- if ( fPrev )
- fPrev->fNext = fNext;
- if ( fNext )
- fNext->fPrev = fPrev;
- }
-
-
- //========================================================================================
- // FrameLink
- //========================================================================================
-
- FrameList::FrameList()
- {
- fFrame = kODNULL;
- fPrev = kODNULL;
- fNext = this;
- }
-
- //----------------------------------------------------------------------------------------
-
- FrameList::~FrameList( )
- {
- // Delete all links:
- while ( fNext != this )
- delete fNext;
- }
-
- //----------------------------------------------------------------------------------------
-
- void FrameList::Add( ODFrame *frame )
- {
- new FrameLink(frame,this);
- // The new link has already hooked itself into my chain so I don't need to
- // remember it elsewhere.
- }
-
- //----------------------------------------------------------------------------------------
-
- void FrameList::Remove( ODFrame *frame )
- {
- for (FrameLink* link = this->First(); link->Frame(); link = link->Next() ) {
- if ( link->Frame() == frame ) {
- delete link;
- return;
- }
- }
- }
-
-
-